using System;
using System.Collections.Generic;
using System.Text;

namespace MindFactorial.LaunchPoint.Console.Library
{
    /// <summary>
    /// represents a collection of plugin windows
    /// </summary>
    public class PluginWindowCollection : ConsoleObject
    {
        Dictionary<string, PluginWindow> _windows = new Dictionary<string,PluginWindow>();

        /// <summary>
        /// adds a new plugin window to the list of available windows
        /// </summary>
        /// <param name="name"></param>
        /// <param name="window"></param>
        public void Add(string name, PluginWindow window)
        {
            if(!_windows.ContainsKey(name))
                _windows.Add(name, window);
            else
                throw new Exception("A5653801-141B-4d65-B0D2-0C25EF4753C3: window name:" + name + " already exists for this plugin." );
        }

        /// <summary>
        /// Gets the specified window from within the collection
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public PluginWindow this[string name]
        {
            get
            {
                if (!_windows.ContainsKey(name))
                    return _windows[name];
                else
                    return null;
            }
        }

        /// <summary>
        /// Gets an enumerator for iterating throught he collection
        /// </summary>
        /// <returns></returns>
        public IEnumerator<PluginWindow> GetEnumerator()
        {
            return _windows.Values.GetEnumerator();
        }
    }
}
